﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using nRoute.Mapping;
using nRoute.Components;
using nRoute.Navigation;

namespace SimpleShell.Views
{
    public partial class About : UserControl, ISupportNavigationViewState
    {
        public About()
        {
            InitializeComponent();
        }

        private void GC_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	GC.Collect();
			GC.Collect();
        }

        public void RestoreState(ParametersCollection state)
        {
            this.MessageText.Text = state.GetValueOrDefault("TEXT", this.MessageText.Text);

            var _offset = default(double);
            if (state.TryGetValue("POS", out _offset))
            {
                LayoutRoot.Loaded += (s, e) => LayoutRoot.ScrollToVerticalOffset(_offset);
            }
        }

        public ParametersCollection SaveState()
        {
            return new ParametersCollection()
            {
                new Parameter("TEXT", MessageText.Text),
                new Parameter("POS", LayoutRoot.VerticalOffset)
            };
        }
    }
}